# Contributor: OIS <mistresssilvara@hotmail.com>
# Maintainer: OIS <mistresssilvara@hotmail.com>
pkgname=sigil
pkgver=1.9.30
pkgrel=2
pkgdesc="EPUB editor"
url="https://sigil-ebook.com/sigil"
# qt6-qtwebengine (XXX: momentarily qt5 for aarch64)
arch="aarch64 x86_64"
license="GPL-3.0-or-later AND Apache-2.0 AND MIT"
depends="
	py3-css-parser
	py3-dulwich
	py3-lxml
	qt5-qtsvg
	"
makedepends="
	cmake
	hunspell-dev
	minizip-dev
	pcre2-dev
	python3-dev
	qt5-qttools-dev
	qt5-qtwebengine-dev
	samurai
	zlib-dev
	"
subpackages="$pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/Sigil-Ebook/Sigil/archive/refs/tags/$pkgver.tar.gz
	$pkgname-assert.patch::https://github.com/Sigil-Ebook/Sigil/commit/8e21405f5d2dfdc7da60f845ae7cf5e2bca6d029.diff
	"
builddir="$srcdir/Sigil-$pkgver/"
# no tests
options="!check"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=Release \
		-DUSE_SYSTEM_LIBS=1 \
		-DINSTALL_BUNDLED_DICTS=0 \
		-DDISABLE_UPDATE_CHECK=1 \
		-DUSE_QT6=OFF \
		$CMAKE_CROSSOPTS

	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

lang() {
	pkgdesc="Languages for package $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"

	amove usr/share/sigil/translations
}

sha512sums="
80dcaa9dcee51c36a42bcd57fc87acda94002af74602d934c7e9bfd275339d9ac200cd1f141fb9e2709ac054569bc22f1869623498ce16c636a3fab8dae4e70f  sigil-1.9.30.tar.gz
eb6a1d6c4cc94833b0356b5ce7b1a168d70dcb77a381b539ce8c5b75ef7cb1f7e5a62ad1c22a5d68105a08758035c654747c1a6e4f638cbc80fd897084db958a  sigil-assert.patch
"
